/**
 * Created by wzm on 2016/12/29.
 */
/*验证手机号*/
jQuery.validator.addMethod('ismobile', function(value, element) {
    var length = value.length;
    var mobile = /^0?(13[0-9]|15[012356789]|18[0-9]|17[0-9])[0-9]{8}$/;
    return this.optional(element) || (length == 11 && mobile.test(value));
}, '请正确填写您的手机号码！')

/*验证IP*/
jQuery.validator.addMethod("checkIp",function (value, element) {
    var regex = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
    return this.optional(element) || regex.test(value);
},"请输入正确的ip！");

/*验证端口号小于65535*/
jQuery.validator.addMethod("checkPort",function (value, element) {
    var regex = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/;
    return this.optional(element)  || regex.test(value);
},"端口号应为小于65535的数字！");

/*验证下拉框*/
jQuery.validator.addMethod("selector",function (value, element) {
    var regex =  /^\+?[0-9]\d*$/;;
    return this.optional(element)  || regex.test(value);
},"必填信息！");

/*logo验证*/
jQuery.validator.addMethod("checkLogo",function (value, element) {
    var  rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i;
    return this.optional(element)  || rFilter.test(element.files[0].type);
},"请选择图片文件！");
